package org.social.db.proxy.bean;

import java.util.Date;

import org.bean.PlayerInfo;
import org.social.db.bean.PlayerMap;

import com.sojoys.artifact.build.data.base.BasePojoProxy;
import com.sojoys.artifact.tools.ToolMap;

/**
 * @author : DengYing
 * @CreateDate : 2018年2月3日 上午11:29:28
 * @Description ：Please describe this document
 */
public class PlayerMapProxy extends BasePojoProxy<PlayerMapProxy, PlayerMap> {
	private boolean online = false;

	public boolean isOnline() {
		return online;
	}

	public void setOnline(boolean onlien) {
		this.online = onlien;
	}

	public Date getLastLoginDate() {
		return ToolMap.getDate(PlayerInfo.LAST_LOGIN_DATE, t.getInfo(),new Date());
	}
	
	public int getPlv() {
		return ToolMap.getInt(PlayerInfo.LVL, t.getInfo());
	}
	
	public int getFightPower() {
		return ToolMap.getInt(PlayerInfo.FIGHT_POWER, t.getInfo());
	}
	
	public String getName() {
		return ToolMap.getString(PlayerInfo.NAME, t.getInfo());
	}
	
	public String getUid() {
		return ToolMap.getString(PlayerInfo.UID, t.getInfo());
	}
	
	public String getLanguage() {
		return ToolMap.getString(PlayerInfo.LANGUAGE, t.getInfo());
	}

	public int getVip() {
		return ToolMap.getInt(PlayerInfo.VIP, t.getInfo());
	}
	
	public int getHelpHeroCid() {
		return ToolMap.getInt(PlayerInfo.HELP_HERO_CID, t.getInfo());
	}
	
	public int getTotalRechargeMoney() {
		return ToolMap.getInt(PlayerInfo.TOTAL_RECHARGE_MONEY, t.getInfo());
	}
	
	public Date getLastOfflineDate() {
		return ToolMap.getDate(PlayerInfo.LAST_OFFLINE_DATE, t.getInfo(),new Date());
	}
	
	public PlayerInfo toPlayerInfo(){
		PlayerInfo playerInfo = new PlayerInfo();
		playerInfo = new PlayerInfo();
		playerInfo.setServerId(t.getServerId());
		playerInfo.setPid(t.getPid());
		playerInfo.setUid(t.getUid());
		
		playerInfo.setName(getName());
		playerInfo.setLanguage(getLanguage());
		playerInfo.setLvl(getPlv());
		playerInfo.setVip(getVip());
		playerInfo.setFightPower(getFightPower());
		playerInfo.setOnline(isOnline());
		playerInfo.setHelpHeroCid(getHelpHeroCid());
		playerInfo.setTotalRechargeMoney(getTotalRechargeMoney());
		playerInfo.setLastLoginDate(getLastLoginDate());
		playerInfo.setLastOfflineDate(getLastOfflineDate());
		return playerInfo;
	}
	
	

	/**
	 * 填充
	 */
	public PlayerInfo fill(PlayerInfo playerInfo){
		
		t.getInfo().put(PlayerInfo.NAME, playerInfo.getName());
		t.getInfo().put(PlayerInfo.LANGUAGE, playerInfo.getLanguage());
		t.getInfo().put(PlayerInfo.LVL, playerInfo.getLvl());
		
		t.getInfo().put(PlayerInfo.VIP, playerInfo.getVip());
		t.getInfo().put(PlayerInfo.FIGHT_POWER, playerInfo.getFightPower());
		t.getInfo().put(PlayerInfo.HELP_HERO_CID, playerInfo.getHelpHeroCid());
		
		t.getInfo().put(PlayerInfo.TOTAL_RECHARGE_MONEY, playerInfo.getTotalRechargeMoney());
		t.getInfo().put(PlayerInfo.LAST_LOGIN_DATE, playerInfo.getLastLoginDate());
		t.getInfo().put(PlayerInfo.LAST_OFFLINE_DATE, playerInfo.getLastOfflineDate());
		
		setOnline(playerInfo.isOnline());
		
		return playerInfo;
	}
}
